class Plugin
  def initialize(class_name)
    @class_name = class_name
  end
  
  def load
    puts "loading \'#{@class_name}\' plugin"
    require("plugins/" + @class_name)
    klass = get_class_for_name(@class_name.capitalize)
    klass.new 
  end
  
  private 
  def get_class_for_name(name, objects = [Object])
    return nil if objects.size == 0
    object = objects.shift
    object.constants.each do |constant_name|
      real_object = object.const_get(constant_name)
      case real_object
      when Class
	return real_object if constant_name == name
      when Module
	objects << real_object
      end
    end
    return get_class_for_name(name, objects)
  end
end 
